/*
 * Copyright (c) $today.year-Now http://www.zxpnet.com All rights reserved.
 */

package com.zxp.security.model;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.io.Serializable;
import java.util.List;

/**
 * @author: shollin
 * @date: 2021/7/4/004 21:05
 */
@Entity(name = "t_role")
@Data
@AllArgsConstructor
@NoArgsConstructor
@JsonIgnoreProperties(value = {"users"},ignoreUnknown = true)
public class Role implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    private String name;

    @ApiModelProperty("中文名称")
    private String cname;

    /**
     * mappedBy表示关系交由User维护, 默认LAZY懒加载
     */
    @ManyToMany(mappedBy = "roles")
    private List<User> users;

    public Role(String name, String cname) {
        this.name = name;
        this.cname = cname;
    }
}
